<?php
/**
 * User: Ngannv
 * Email: ngankt2@gmail.com
 * Y!M : ngankt2
 * Date: 9/4/11
 * Time: 12:23 PM
 */

if (!file_exists(APP_DIR . 'libraries/jUrl.php')) {
    die('Cannot access !');
}
require_once APP_DIR . 'libraries/jUrl.php';
//require_once APP_DIR . 'libraries/jGlobal.php';
class jAjax
{
    function __construct($newClass, $param = NULL)
    {
        if (class_exists($newClass)) {
            $newAjaxController = new $newClass($param);
            if (method_exists($newAjaxController, 'index')) {
                $newAjaxController->index();
            } else {
                die('Cannot access');
            }
        } else {
            die('Cannot access!');
        }
    }
}

/*Config*/
$controller = jUrl::getParam('ctr');
$isMainController = jUrl::getParam('');
if ($controller) {
    $file_inc = CONTROL_DIR . $controller . $controller . 'Ajax.php';
    if (file_exists($file_inc)) {
        require_once $file_inc;
        new jAjax($controller);
    }
}
